petitcomputerfandomcom-20200214-history
COLSET (Command)
V1 Indications are, COLSET in SmileBasic V1 is identical to that in V2. V2 COLSET is a command which alters which colours are available to the graphics system. It has three parameters. The first is a string, and should be "BG", "SP", or "GRP" (anything else results in Illegal function call (COLSET) error). The second is a number, which is rounded down to an integer, and the rounded value should be between 0 and 255 inclusive (anything else results in Out of range (COLSET) error). The third is a string of six hexadecimal characters (upper and lowercase are both permitted). Any string of fewer than 6 characters generates an Illegal function call error, as will a string of 6 characters which are not all hexadecimal values. Some strings longer than 6 characters will also give an Illegal function call error, but others will cause the system to entirely stop responding (precisely which ones, under which circumstances, is not clear). The first pair of hexadecimal digits refers to an intensity of red, the second pair to an intensity of green, and the third pair to an intensity of blue. Though there is 8 bits of accuracy in a pair of hexadecimal digits, the red and blue values are only stored to 5 bits of accuracy, and green is stored to 6 bits of accuracy. So, for example, if "03" is used in COLSET, then COLREAD on the colour will give a result of 0, but if "08" is used, COLREAD will give the value 8. The following tables give the relationship between values written using COLSET, and values read using COLREAD. For R or B values: COLREAD 0 8 16 25 33 41 49 58 66 74 82 90 99 107 115 123 132 140 148 156 165 173 181 189 197 206 214 222 230 239 247 255 COLSET 0 to 7 8 to 15 16 to 23 24 to 31 32 to 39 40 to 47 48 to 55 56 to 63 64 to 71 72 to 79 80 to 87 88 to 95 96 to 103 104 to 111 112 to 119 120 to 127 128 to 135 136 to 143 144 to 151 152 to 159 160 to 167 168 to 175 176 to 183 184 to 191 192 to 199 200 to 207 208 to 215 216 to 223 224 to 231 232 to 239 240 to 247 248 to 255 The above table can be summarized as follows. For any value on the bottom row, round it down to the nearest multiple of 8, multiply by 255/248, then round to the nearest integer. For G values, there is a similar table, except the steps are to round down to the nearest multiple of 4, multiply by 255/252, then round to the nearest integer. (This kind of conversion happens when you wish to quantize a range of values to a smaller set: the set of values 0 to 255 is divided into equal partitions, and each partition is given an integer number spaced as evenly as possible so the lowest is 0 and the highest is 255. Consider the smaller example of the range from 0 to 7, partitioned into 4 sets. Each set will be two numbers: {0, 1}, {2, 3}, {4, 5}, {6, 7}. The lowest number is 0, the highest is 7, there are 4 partitions, so the most regular way to associate numbers with the partitions is 0, 2, 5, 7. So, 0 to 1 becomes 0, 2 to 3 becomes 2, 4 to 5 becomes 5, and 6 to 7 becomes 7.) V3 No information on SmileBasic V3. Category:Resources Category:System Guides Category:Commands